home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / mac / files / dsp / a5611.tz / a5611 / a56.l < prev    next >
Text File  |  1992-08-11  |  9KB  |  265 lines

  1. %{
  2. /*
  3.  * Copyright (C) 1990-1992 Quinn C. Jensen
  4.  *
  5.  * Permission to use, copy, modify, distribute, and sell this software
  6.  * and its documentation for any purpose is hereby granted without fee,
  7.  * provided that the above copyright notice appear in all copies and
  8.  * that both that copyright notice and this permission notice appear
  9.  * in supporting documentation.  The author makes no representations
  10.  * about the suitability of this software for any purpose.  It is
  11.  * provided "as is" without express or implied warranty.
  12.  *
  13.  */
  14. %}
  15. %a    10000
  16. %o    10000
  17. %e    2000
  18. %k    2000
  19. %p    3000
  20. A    [Aa]
  21. B    [Bb]
  22. C    [Cc]
  23. D    [Dd]
  24. E    [Ee]
  25. F    [Ff]
  26. G    [Gg]
  27. H    [Hh]
  28. I    [Ii]
  29. J    [Jj]
  30. K    [Kk]
  31. L    [Ll]
  32. M    [Mm]
  33. N    [Nn]
  34. O    [Oo]
  35. P    [Pp]
  36. Q    [Qq]
  37. R    [Rr]
  38. S    [Ss]
  39. T    [Tt]
  40. U    [Uu]
  41. V    [Vv]
  42. W    [Ww]
  43. X    [Xx]
  44. Y    [Yy]
  45. Z    [Zz]
  46. WHITE    [ \t]+
  47. ALCHR    [_A-Za-z]
  48. ALPHA    {ALCHR}+
  49. NUM    [0-9]+
  50. FRAC    ("-"|"")({NUM}"."{NUM})|("."{NUM})
  51. ALNUM    {ALCHR}[0-9A-Za-z_]*
  52. HEXNUM    [0-9A-Fa-f]+
  53. BW    (^|{WHITE})
  54. %%
  55. {WHITE}            ;
  56. \n            {curline++; RET(EOL);}
  57. @            {RET(EOS);}
  58. ;.*$            {RET(COMMENT);}
  59. {X}:            {RET(XMEM);}
  60. {Y}:            {RET(YMEM);}
  61. {L}:            {RET(LMEM);}
  62. {P}:            {RET(PMEM);}
  63. {A}10            {RET(A10);}
  64. {A}            {RET(AAAA);}
  65. {B}10            {RET(B10);}
  66. {B}            {RET(BBBB);}
  67. {A}{B}            {RET(AABB);}
  68. {B}{A}            {RET(BBAA);}
  69. {X}            {RET(XXXX);}
  70. {Y}            {RET(YYYY);}
  71. {S}{R}            {RET(SR);}
  72. {M}{R}            {RET(MR);}
  73. {C}{C}{R}        {RET(CCR);}
  74. {O}{M}{R}        {RET(OMR);}
  75. {S}{P}            {RET(SP);}
  76. {S}{S}{H}        {RET(SSH);}
  77. {S}{S}{L}        {RET(SSL);}
  78. {L}{A}            {RET(LA);}
  79. {L}{C}            {RET(LC);}
  80. {A}[0-2]        {yylval.ival = atoi(&yytext[1]); RET(AREG);}
  81. {B}[0-2]        {yylval.ival = atoi(&yytext[1]); RET(BREG);}
  82. {M}[0-7]        {yylval.ival = atoi(&yytext[1]); RET(MREG);}
  83. {N}[0-7]        {yylval.ival = atoi(&yytext[1]); RET(NREG);}
  84. {R}[0-7]        {yylval.ival = atoi(&yytext[1]); RET(RREG);}
  85. {X}[01]            {yylval.ival = atoi(&yytext[1]); RET(XREG);}
  86. {Y}[01]            {yylval.ival = atoi(&yytext[1]); RET(YREG);}
  87. "$"{HEXNUM}        {yylval.n.type = INT; yylval.n.val.i = strtol(&yytext[1], 0, 16); RET(CHEX);}
  88. {FRAC}            {yylval.n.type = FLT; yylval.n.val.f = atof(yytext); RET(FRAC);}
  89. {NUM}            {yylval.n.type = INT; yylval.n.val.i = atoi(yytext); RET(CDEC);}
  90. {A}{B}{S}               {RET(OP_ABS);}
  91. {A}{D}{C}               {RET(OP_ADC);}
  92. {A}{D}{D}               {RET(OP_ADD);}
  93. {A}{D}{D}{L}            {RET(OP_ADDL);}
  94. {A}{D}{D}{R}            {RET(OP_ADDR);}
  95. {A}{S}{L}               {RET(OP_ASL);}
  96. {A}{S}{R}               {RET(OP_ASR);}
  97. {C}{L}{R}               {RET(OP_CLR);}
  98. {C}{M}{P}               {RET(OP_CMP);}
  99. {C}{M}{P}{M}            {RET(OP_CMPM);}
  100. {D}{I}{V}               {RET(OP_DIV);}
  101. {M}{A}{C}               {RET(OP_MAC);}
  102. {M}{A}{C}{R}            {RET(OP_MACR);}
  103. {M}{P}{Y}               {RET(OP_MPY);}
  104. {M}{P}{Y}{R}            {RET(OP_MPYR);}
  105. {N}{E}{G}               {RET(OP_NEG);}
  106. {N}{O}{R}{M}            {RET(OP_NORM);}
  107. {R}{N}{D}               {RET(OP_RND);}
  108. {S}{B}{C}               {RET(OP_SBC);}
  109. {S}{U}{B}               {RET(OP_SUB);}
  110. {S}{U}{B}{L}            {RET(OP_SUBL);}
  111. {S}{U}{B}{R}            {RET(OP_SUBR);}
  112. {T}{C}{C}               {yylval.cond = 0x0; RET(OP_TCC);}
  113. {T}{H}{S}               {yylval.cond = 0x0; RET(OP_TCC);}
  114. {T}{G}{E}               {yylval.cond = 0x1; RET(OP_TCC);}
  115. {T}{N}{E}               {yylval.cond = 0x2; RET(OP_TCC);}
  116. {T}{P}{L}               {yylval.cond = 0x3; RET(OP_TCC);}
  117. {T}{N}{N}               {yylval.cond = 0x4; RET(OP_TCC);}
  118. {T}{E}{C}               {yylval.cond = 0x5; RET(OP_TCC);}
  119. {T}{L}{C}               {yylval.cond = 0x6; RET(OP_TCC);}
  120. {T}{G}{T}               {yylval.cond = 0x7; RET(OP_TCC);}
  121. {T}{C}{S}               {yylval.cond = 0x8; RET(OP_TCC);}
  122. {T}{L}{O}               {yylval.cond = 0x8; RET(OP_TCC);}
  123. {T}{L}{T}               {yylval.cond = 0x9; RET(OP_TCC);}
  124. {T}{E}{Q}               {yylval.cond = 0xA; RET(OP_TCC);}
  125. {T}{M}{I}               {yylval.cond = 0xB; RET(OP_TCC);}
  126. {T}{N}{R}               {yylval.cond = 0xC; RET(OP_TCC);}
  127. {T}{E}{S}               {yylval.cond = 0xD; RET(OP_TCC);}
  128. {T}{L}{S}               {yylval.cond = 0xE; RET(OP_TCC);}
  129. {T}{L}{E}               {yylval.cond = 0xF; RET(OP_TCC);}
  130. {T}{F}{R}               {RET(OP_TFR);}
  131. {T}{S}{T}               {RET(OP_TST);}
  132. {A}{N}{D}               {RET(OP_AND);}
  133. {A}{N}{D}{I}            {RET(OP_ANDI);}
  134. {E}{O}{R}               {RET(OP_EOR);}
  135. {L}{S}{L}               {RET(OP_LSL);}
  136. {L}{S}{R}               {RET(OP_LSR);}
  137. {N}{O}{T}               {RET(OP_NOT);}
  138. {O}{R}                  {RET(OP_OR);}
  139. {O}{R}{I}               {RET(OP_ORI);}
  140. {R}{O}{L}               {RET(OP_ROL);}
  141. {R}{O}{R}               {RET(OP_ROR);}
  142. {B}{C}{L}{R}            {RET(OP_BCLR);}
  143. {B}{S}{E}{T}            {RET(OP_BSET);}
  144. {B}{C}{H}{G}            {RET(OP_BCHG);}
  145. {B}{T}{S}{T}            {RET(OP_BTST);}
  146. {D}{O}                  {RET(OP_DO);}
  147. {E}{N}{D}{D}{O}         {RET(OP_ENDDO);}
  148. {L}{U}{A}               {RET(OP_LUA);}
  149. {M}{O}{V}{E}            {RET(OP_MOVE);}
  150. {M}{O}{V}{E}{C}         {RET(OP_MOVEC);}
  151. {M}{O}{V}{E}{M}         {RET(OP_MOVEM);}
  152. {M}{O}{V}{E}{P}         {RET(OP_MOVEP);}
  153. {I}{N}{C}{L}{U}{D}{E}   {RET(OP_INCLUDE);}
  154. {I}{L}{L}{E}{G}{A}{L}   {RET(OP_ILLEGAL);}
  155. {J}{C}{C}               {yylval.cond = 0x0; RET(OP_JCC);}
  156. {J}{H}{S}               {yylval.cond = 0x0; RET(OP_JCC);}
  157. {J}{G}{E}               {yylval.cond = 0x1; RET(OP_JCC);}
  158. {J}{N}{E}               {yylval.cond = 0x2; RET(OP_JCC);}
  159. {J}{P}{L}               {yylval.cond = 0x3; RET(OP_JCC);}
  160. {J}{N}{N}               {yylval.cond = 0x4; RET(OP_JCC);}
  161. {J}{E}{C}               {yylval.cond = 0x5; RET(OP_JCC);}
  162. {J}{L}{C}               {yylval.cond = 0x6; RET(OP_JCC);}
  163. {J}{G}{T}               {yylval.cond = 0x7; RET(OP_JCC);}
  164. {J}{C}{S}               {yylval.cond = 0x8; RET(OP_JCC);}
  165. {J}{L}{O}               {yylval.cond = 0x8; RET(OP_JCC);}
  166. {J}{L}{T}               {yylval.cond = 0x9; RET(OP_JCC);}
  167. {J}{E}{Q}               {yylval.cond = 0xA; RET(OP_JCC);}
  168. {J}{M}{I}               {yylval.cond = 0xB; RET(OP_JCC);}
  169. {J}{N}{R}               {yylval.cond = 0xC; RET(OP_JCC);}
  170. {J}{E}{S}               {yylval.cond = 0xD; RET(OP_JCC);}
  171. {J}{L}{S}               {yylval.cond = 0xE; RET(OP_JCC);}
  172. {J}{L}{E}               {yylval.cond = 0xF; RET(OP_JCC);}
  173. {J}{M}{P}               {RET(OP_JMP);}
  174. {J}{C}{L}{R}            {RET(OP_JCLR);}
  175. {J}{S}{E}{T}            {RET(OP_JSET);}
  176. {J}{S}{C}{C}            {yylval.cond = 0x0; RET(OP_JSCC);}
  177. {J}{S}{H}{S}            {yylval.cond = 0x0; RET(OP_JSCC);}
  178. {J}{S}{G}{E}            {yylval.cond = 0x1; RET(OP_JSCC);}
  179. {J}{S}{N}{E}            {yylval.cond = 0x2; RET(OP_JSCC);}
  180. {J}{S}{P}{L}            {yylval.cond = 0x3; RET(OP_JSCC);}
  181. {J}{S}{N}{N}            {yylval.cond = 0x4; RET(OP_JSCC);}
  182. {J}{S}{E}{C}            {yylval.cond = 0x5; RET(OP_JSCC);}
  183. {J}{S}{L}{C}            {yylval.cond = 0x6; RET(OP_JSCC);}
  184. {J}{S}{G}{T}            {yylval.cond = 0x7; RET(OP_JSCC);}
  185. {J}{S}{C}{S}            {yylval.cond = 0x8; RET(OP_JSCC);}
  186. {J}{S}{L}{O}            {yylval.cond = 0x8; RET(OP_JSCC);}
  187. {J}{S}{L}{T}            {yylval.cond = 0x9; RET(OP_JSCC);}
  188. {J}{S}{E}{Q}            {yylval.cond = 0xA; RET(OP_JSCC);}
  189. {J}{S}{M}{I}            {yylval.cond = 0xB; RET(OP_JSCC);}
  190. {J}{S}{N}{R}            {yylval.cond = 0xC; RET(OP_JSCC);}
  191. {J}{S}{E}{S}            {yylval.cond = 0xD; RET(OP_JSCC);}
  192. {J}{S}{L}{S}            {yylval.cond = 0xE; RET(OP_JSCC);}
  193. {J}{S}{L}{E}            {yylval.cond = 0xF; RET(OP_JSCC);}
  194. {J}{S}{R}               {RET(OP_JSR);}
  195. {J}{S}{C}{L}{R}         {RET(OP_JSCLR);}
  196. {J}{S}{S}{E}{T}         {RET(OP_JSSET);}
  197. {N}{O}{P}               {RET(OP_NOP);}
  198. {R}{E}{P}               {RET(OP_REP);}
  199. {R}{E}{S}{E}{T}         {RET(OP_RESET);}
  200. {R}{T}{I}               {RET(OP_RTI);}
  201. {R}{T}{S}               {RET(OP_RTS);}
  202. {S}{T}{O}{P}            {RET(OP_STOP);}
  203. {S}{W}{I}               {RET(OP_SWI);}
  204. {W}{A}{I}{T}            {RET(OP_WAIT);}
  205. {E}{Q}{U}               {RET(OP_EQU);}
  206. {O}{R}{G}               {RET(OP_ORG);}
  207. {D}{C}                  {RET(OP_DC);}
  208. {E}{N}{D}               {RET(OP_END);}
  209. {P}{A}{G}{E}            {RET(OP_PAGE);}
  210. {P}{S}{E}{C}{T}         {RET(OP_PSECT);}
  211. {A}{L}{I}{G}{N}         {RET(OP_ALIGN);}
  212. {ALNUM}            {yylval.sval = strsave(yytext); RET(SYM);};
  213. '\\b'            {yylval.cval = '\b'; RET(CHAR);};
  214. '\\f'            {yylval.cval = '\f'; RET(CHAR);};
  215. '\\n'            {yylval.cval = '\n'; RET(CHAR);};
  216. '\\r'            {yylval.cval = '\r'; RET(CHAR);};
  217. '\\t'            {yylval.cval = '\t'; RET(CHAR);};
  218. '\\\\'            {yylval.cval = '\\'; RET(CHAR);};
  219. '.'            {yylval.cval = yytext[1]; RET(CHAR);};
  220. \".*\"            |
  221. '..+'            {yylval.sval = (char *)fixstring(yytext);
  222.                 yylval.sval = strsave(yylval.sval);
  223.                 RET(STRING);};
  224. "<<"            {RET(SHL);};
  225. ">>"            {RET(SHR);};
  226. .            {RET(yytext[0]);}
  227. %%
  228.  
  229. #undef input
  230. #define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):lgetc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)
  231.  
  232. #define INLINE 1024
  233.  
  234. char inline[INLINE], *ip = NULL;
  235.  
  236. lgetc(fp)
  237. FILE *fp;
  238. {
  239.     int c;
  240.  
  241.     if(NOT ip) {
  242.     if(NOT fgets(inline, INLINE, fp))
  243.         return(EOF);
  244.     rmcr(inline);
  245.     ip = inline;
  246.     }
  247.     c = *ip;
  248.  
  249.     if(ldebug) {
  250.     printf("i='%c'(%x)", c, c);
  251.     fflush(stdout);
  252.     }
  253.  
  254.     switch(c) {
  255.     case '\0':
  256.         c = '\n';
  257.         ip = NULL;
  258.         break;
  259.     default:
  260.         ip++;
  261.         break;
  262.     }
  263.     return(c);
  264. }
  265.